import sys
import time
import win32api
import os

def main():
    sys.stdout = open('C:\\tmp\\noscreensaver.log', 'wb', 0)
    print os.getpid()
    #cnt = 0
    while True:
        time.sleep(120)
        win32api.mouse_event(1,0,0,0,0)
        #lst = win32api.GetLastInputInfo()
        #tick = win32api.GetTickCount()
        #print "tick is %d"%tick
        #print "lst is %d"%lst
        '''lst = win32api.GetLastInputInfo()
        tick = win32api.GetTickCount()
        print "tick is %d"%tick
        print "lst is %d"%lst
        if ( tick - lst ) < 1*60*1000:
            print "stop "
            flg = False
            cnt = 0
        else:
            print "start "
            flg = True
        if flg and (tick - lst) >= 4*60*1000:
            cnt = cnt + 1
            if cnt <= 5:
                print "send mouse message"
                win32api.mouse_event(1,0,0,0,0)
        '''
    return 0
if __name__ == '__main__':
    sys.exit(main())